package src.com.test.twoDay;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class demo3 {

    List<List<Integer>> res = new ArrayList<>();
    LinkedList<Integer> path = new LinkedList<>();

    public List<List<Integer>> subsets(int[] nums) {

        tracebacking(nums,0);
        return res;
    }
    public void tracebacking(int[] nums,int index){

        res.add(new ArrayList<>(path));

        if (index >= nums.length){
            return;
        }

        for(int i = index;i < nums.length;i++){

            path.add(nums[i]);
            tracebacking(nums,i + 1);
            path.removeLast();
        }
    }
}
